<%--
  Created by IntelliJ IDEA.
  User: wyp
  Date: 2020/5/16
  Time: 14:35
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <!--引入JQuery，必须要在bootstrap.js之前引入-->
    <script type="text/javascript" src="./resources/js/jquery-3.4.1.min.js"></script>
    <link rel="stylesheet" href="./resources/css/font.css">
    <link rel="stylesheet" href="./resources/css/xadmin.css">
    <!-- <link rel="stylesheet" href="./css/theme5.css"> -->
    <script src="./resources/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="./resources/js/xadmin.js"></script>
    <title>旅游公司添加</title>
</head>
<script>
    layui.use(['form','layer','jquery'],
        function () {
            $ = layui.jquery;
            var form = layui.form,
                layer = layui.layer;

            //当companyAdd按钮提交后，执行
            form.on('submit(companyAdd)',
                function(data) {
                    console.log(data);
                    //获取参数
                    var companyName = $('#companyName').val();
                    var userName = $('#userName').val();
                    var userPassword = $('#userPassword').val();
                    var userTel = $('#userTel').val();

                    $.ajax({
                        type:"POST",
                        data:{"method":"companyAdd","companyName":companyName,"userName":userName,
                            "userPassword":userPassword,"userTel":userTel},
                        url:"./companyControl",
                        dataType:"json",
                        success:function (data) {
                            layer.alert("增加成功",{icon:6},function () {
                                xadmin.close();
                                // 可以对父窗口进行刷新
                                xadmin.father_reload();
                            });
                        },
                        error:function (data) {
                            layer.alert("增加失败",{icon:6},function () {
                                xadmin.close();
                                // 可以对父窗口进行刷新
                                xadmin.father_reload();
                            });
                        }
                    });
                    return false;
                });


    });
</script>
<body>
    <div class="layui-fluid" >
        <div class="layui-row">
            <form class="layui-form" method="post" >
                <div class="layui-form-item">
                    <label for="companyName" class="layui-form-label">
                        <span class="x-red">*</span>公司名称
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="companyName" name="companyName" required="required" lay-verify="companyName" autocomplete="off" class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label for="userName" class="layui-form-label">
                        <span class="x-red">*</span>用户名
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="userName" name="userName" required="" lay-verify="userName" autocomplete="off" class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label for="userPassword" class="layui-form-label">
                        <span class="x-red">*</span>密码
                    </label>
                    <div class="layui-input-inline">
                        <input type="password" id="userPassword" name="userPassword" required="" lay-verify="userPassword" autocomplete="off" class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label for="userTel" class="layui-form-label">
                        <span class="x-red">*</span>联系电话
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="userTel" name="userTel" required="" lay-verify="userTel" autocomplete="off" class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item">
                    <button class="layui-btn" lay-filter="companyAdd" lay-submit="">增加</button>
                </div>
            </form>
        </div>
    </div>
</body>
</html>
